/*
 * @LastEditors: yuSeen
 * @LastEditTime: 2021-11-19 20:23:25
 * 天凉好个秋
 */
import { Context, Next } from "koa";
import requestParams from "../../utils/requestParams";
import { accessLogger } from "../logger";

// 接口访问日志
export default (ctx: Context, next: Next) => {
    const { path, method, headers } = ctx
    const params = JSON.stringify(requestParams(ctx))
    const msg = `path: ${path} | method: ${method} | params: ${params} | ua: ${headers["user-agent"]}`
    accessLogger.info(msg)
    return next()
}